import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'

export function getToken () {
    return Cookies.get(TokenKey)
}

export function getUserinfo () {
    return {
        user: Cookies.get('user'),
        roles: Cookies.get('user'),
        name: Cookies.get('name'),
        img: Cookies.get('img')
    }
}

export function setToken (data) {
    // return Cookies.set(TokenKey, token)
    Cookies.set('user', data.user)
    Cookies.set('roles', data.roles)
    Cookies.set('name', data.name)
    Cookies.set('img', data.img)
    // console.log('TokenKey',Cookies.get(TokenKey))
    return Cookies.set(TokenKey, data.token)
}

export function removeToken () {
    return Cookies.remove(TokenKey)
}
